<template>
	<view>
		<!-- camera.wxml -->
		<camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>
		<button type="primary" bindtap="takePhoto">拍照</button>
		<view>预览</view>
		<image mode="widthFix" src="{{}}"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: ""
			}
		},
		methods: {
			takePhoto() {
			    const ctx = wx.createCameraContext()
			    ctx.takePhoto({
			      quality: 'high',
			      success: (res) => {
			        this.setData({
			          src: res.tempImagePath
			        })
			      }
			    })
			  },
			  error(e) {
			    console.log(e.detail)
			  }
		}
	}
</script>

<style>

</style>
